package tool;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import guru.nidi.graphviz.engine.Format;
import guru.nidi.graphviz.model.Graph;
import tool.cfgformats.GraphBuilder;
import tool.model.CfgGenerator;
import tool.model.cfg.EntryNode;

public class CTest {

	public static String fileName = "E:\\temp\\prime.c";
	public static HashMap<String, ArrayList<EntryNode>> cfgs;
	public static Map<String, Map> map;

	public static void main(String[] args) {
		CfgGenerator cfgGenerator = new CfgGenerator();
		cfgs = cfgGenerator.generateCCfg(fileName);

		GraphBuilder graphBuilder = new GraphBuilder();
		List<EntryNode> cfgList = new ArrayList<>();
		for (ArrayList<EntryNode> list : cfgs.values()) {
			cfgList.addAll(list);
		}

		Map<String, Graph> graphs = graphBuilder.createGraphs(cfgList);
		Graph graph = graphBuilder.createGraph(cfgList);
		graphBuilder.exportGraph(graph, fileName, Format.PNG);
	}

}
